package com.jiazhong.shixi.caichanguanli.controller;

import com.jiazhong.shixi.caichanguanli.bean.RepairRecords;
import com.jiazhong.shixi.caichanguanli.mapper.RepairRecordsMapper;
import com.jiazhong.shixi.caichanguanli.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.net.URI;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@CrossOrigin("*")
@RestController
@RequestMapping("/repair")
public class RepairRecordsController {
    @Resource
    private RepairRecordsMapper repairRecordsMapper;

    @RequestMapping("/add")
    public JsonResult addRepair(RepairRecords sc) {
        System.out.println(sc);
        repairRecordsMapper.add(sc);
        JsonResult result = new JsonResult(true, 200, "success", "");
        return result;
    }

    @RequestMapping("/status")
    public JsonResult updateStatus(RepairRecords sc) {
        repairRecordsMapper.updateStatus(sc);
        JsonResult result = new JsonResult(true, 200, "success", "");
        return result;
    }

    @RequestMapping("/select")
    public JsonResult findByCreateTime() {
        List<RepairRecords> list  =repairRecordsMapper.findByCreateTime();
        JsonResult result = new JsonResult(true, 200, list, "");
        return result;
    }
    @RequestMapping("/create")
    public JsonResult findByCreate() {
        List<RepairRecords> list  =repairRecordsMapper.findByCreate();
        JsonResult result = new JsonResult(true, 200, list, "");
        return result;
    }

}

